package test.san.baseproject.util

import test.san.baseproject.R
import test.san.baseproject.base.BaseFragmnet
import test.san.baseproject.ui.fragment.HomeFragment
import test.san.baseproject.ui.fragment.MVFragment
import test.san.baseproject.ui.fragment.VBangFragment
import test.san.baseproject.ui.fragment.YueDanFragment


// 单例管理所有Fragment

class FragmentUtil private constructor() {

    private val homeFragment by lazy { HomeFragment() }
    private val mvFragment by lazy { MVFragment() }
    private val vbandFragment by lazy { VBangFragment() }
    private val yuedanFragment by lazy { YueDanFragment() }

    companion object {
        val fragmentUtil by lazy { FragmentUtil() }
    }


    public fun getFragment(id: Int) : BaseFragmnet? {
        when(id) {
            R.id.tab_home -> {
                return  homeFragment
            }
            R.id.tab_mv -> {
                return  mvFragment
            }
            R.id.tab_vbang -> {
                return  vbandFragment
            }
            R.id.tab_yuedan -> {
                return  yuedanFragment
            }
        }
        return null
    }
}